#include "ArmyEntity.h"




ArmyEntity::ArmyEntity(int id, int type, double x, double y, Rect* rangeOfEffect)
{
	initData(id, type, x, y, rangeOfEffect);
}

void ArmyEntity::initData(int id, int type, double x, double y, Rect* rangeOfEffect)
{
	_armyData = new ArmyData(id, type, x, y, rangeOfEffect);
}

void ArmyEntity::initData()
{

}

AbstractData* ArmyEntity::getData()
{
	return _armyData;
}

void ArmyEntity::draw(long time)
{
	if (_armyData->isDead) return;
	_armyState->draw(time);
}

void ArmyEntity::update(long time)
{
	//if (!_armyData->isDead) {
	_armyState->update(time);
	_armyPhysics->update(time);
	//}
}

void ArmyEntity::setRefPattern(IArmyState* state, IArmyPhysics* physics)
{
	_armyState = state != NULL ? state : _armyState;
	_armyPhysics = physics != NULL ? physics : _armyPhysics;
}

void ArmyEntity::setTargetRect(Rect* target)
{
	_armyData->targetRect = target;
}

AbstractData* ArmyEntity::getAbstractData()
{
	return _armyData;
}

ArmyData* ArmyEntity::getArmyData()
{
	return _armyData;
}

void ArmyEntity::updateData(int type, int action)
{
	if (type == (int) ACTIONS_IS_HURT) {
		_armyPhysics->setIsHurt(ACTIONS_IS_HURT, action);
	}
}
